/**
 * @FrameBitmapData.as
 *
 * @author sodaChen mail:asframe@qq.com
 * @version 1.0
 * <br>Copyright (C), 2013 ASFrame.com
 * <br>This program is protected by copyright laws.
 * <br>Program Name:ASFrame GameEngine
 * <br>Date:2013-6-22
 */
package com.asframe.display.data
{
	import flash.display.BitmapData;
	import flash.geom.Rectangle;

	/**
	 * 一帧的BitmapData相关数据
	 * @author sodaChen
	 * #Date:2013-6-22
	 */
	public class FrameData
	{
		/** 每帧的图像信息 **/
		public var bitmapData:BitmapData;
		/** 旋转值 **/
		public var rotation:Number = 0;
		public var x:int;
		public var y:int;
		public var width:int;
		public var height:int;
		/** 实际图像矩形范围 **/
		public var rect:Rectangle;
		/** 附加的额外数据 **/
		public var extra:*;
		public function FrameData(bitmapData:BitmapData = null,rect:Rectangle = null,extra:Object = null)
		{
			if(bitmapData != null)
				initFrames(bitmapData,rect,extra);
		}
		public function initFrames(bitmapData:BitmapData,rect:Rectangle,extra:Object = null):void
		{
			this.bitmapData = bitmapData;
			this.rect = rect;
			this.extra = extra;
			if(rect == null)
			{
				this.x = 0;
				this.y = 0;
				this.width = bitmapData.width;
				this.height = bitmapData.height;
			}
			else
			{
				this.x = rect.x;
				this.y = rect.y;
				this.width = rect.width;
				this.height = rect.height;
			}
		}
		public function destory():void
		{
			bitmapData.dispose();
			bitmapData = null;
			rect = null;
		}
	}
}
